#pragma once
#include "stdafx.h"
#include <boost/noncopyable.hpp>
#include <event2/event.h>
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include <boost/shared_ptr.hpp>
#include "SocketStreamInput.h"
#include "SocketStreamOutput.h"
#include "CommandManager.h"
class IOManager:private boost::noncopyable
{
private:
	static IOManager * ioManager;
	
public:
	std::map<SocketStreamOutput*, struct evbuffer*> outputMap;
	 
	struct event_base * base;
	IOManager(void);
	~IOManager(void);
	static IOManager* getInstance(void);
	//receive the input stream by socket 
	void addStreamInput(std::string ip,std::string port, SocketStreamInput* streamInput);
	//export the output stream by socket 
	bool addStreamOutput(std::string ip,std::string port, SocketStreamOutput* streamOutput);
	//execute one time to see if any event may be happened, if yes, the registered function handler woule be called
	void executeOnce(void);
	//write output to the socket
	bool writeOutput(char* buffer, int length,SocketStreamOutput* streamOutput);

	//receive command by socket
	void addCommandInput(std::string ip,std::string port, CommandManager* commandManager);

	 
	 
};

